// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import Vuex from 'vuex';
import router from './router'
import Util from './libs/util';
import axios from 'axios'
import ajax from './libs/axios';
import lodash from 'lodash';
import config from './config/config';
import VueLocalStorage from 'vue-ls';
import jshashes from 'jshashes';
//注册vuelocalstorage插件
Vue.use(VueLocalStorage, {
    namespace: 'vuejs__'
});
Vue.use(Vuex);
//注册jshashes插件
Vue.use(jshashes);
Vue.prototype.$ajax = ajax;
Vue.prototype.$axios = axios.create(
    config.axios
);
const store = new Vuex.Store({
    state: {
        identifying:'',
        appid:'',
        operation:'',
        //验证状态
        success:false,
        //验证值
        value:'',
        //验证类型
        type:'',
        //验证组件状态
        validation:true,
        //主题
        theme:''
    },
    getters: {
        //获取
    },
    mutations: {
        set_identifying(state, identifying) {
            state.identifying = identifying;
        },
        set_appid(state,appid){
            state.appid = appid;
        },
        set_operation(state,operation){
            state.operation=operation;
        },
        set_success(state,success){
            state.success=success;
        },
        //获取验证值
        set_value(state,value){
            state.value=value;
        },
        //获取验证类型
        set_type(state,type){
          state.type=type;
        },
        //验证组件验证错误
        set_validation(state){
          state.validation=false;
        },
        //获取主题
        set_theme(state,theme){
          state.theme=theme;
        }
    },
    actions: {
        //动作
        save_identifying(context,identifying) {
            context.commit('set_identifying',identifying);
        },
        save_appid(context,appid) {
          context.commit('set_appid',appid);
        },
        save_operation(context,operation) {
          context.commit('set_operation',operation);
        },
        save_success(context,success) {
          context.commit('set_success',success);
        },
        //获取验证值
        save_value(context,value){
          context.commit('set_value',value);
        },
        //获取验证类型
        save_type(context,type){
          context.commit('set_type',type);
        },
        //验证组件验证错误
        save_validation(context){
          context.commit('set_validation');
        },
        //获取主题
        save_theme(context,theme){
          context.commit('set_theme',theme);
        }
    }
});
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  _: lodash,
  ajax: ajax,
  store: store,
  template: '<App/>',
  components: { App }
})
